global dir "/Users/gsms data"

cd "$dir"

clear
set mem 100m
clear mata
clear matrix
set maxvar 8000
set more off

*************************************************************
*************************************************************
*************************************************************
***** Appendix Tables  *****************
*************************************************************
*************************************************************
*************************************************************





*** Note: This data is created in: data_creation_gsms_main.do

use gsms_main, clear

/* Aopendix Table 1 Means BEGIN */
gen ai_par_tt = ai_par_t
recode ai_par_tt 2=1

gen avghhincome_dollars = avghhincome*5000
bysort ai_par_tt: sum ag1 ag2 ag3 age sex avghhincome_dollars marr mhs mcol  ftm   if wave ==1, sep(0)
foreach var in ag1 ag2 ag3 age sex avghhincome_dollars marr mhs mcol  ftm  {
	ttest `var' if wave ==1, by(ai_par_tt) 
	}
	
 use gsms_diff_diff_16_finished.dta, clear	
bysort raceai_new    : sum parent_base_prop_vote	if parent ==0
		ttest parent_base_prop_vote if parent ==0, by(raceai_new) 

/* Appendix Table 1 Means END */







/* Appendix Table 2 Matching Rates BEGIN */

use temp, replace
 
 reg live_outside_nc_p1 t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
 outreg2 using matches.xls, replace  keep(t1_new t2_new) 
 reg live_outside_nc_p1 t1_new t2_new ag1_new ag2_new ai_par_t_new       sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
 outreg2 using matches.xls, append  keep(t1_new t2_new) 
 reg live_outside_nc_p1 t1_new t2_new ag1_new ag2_new ai_par_t_new       sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
 outreg2 using matches.xls, append  keep(t1_new t2_new) 
 
 reg changed_last_name_p1 t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
 outreg2 using matches.xls, append  keep(t1_new t2_new) 
 reg changed_last_name_p1 t1_new t2_new ag1_new ag2_new ai_par_t_new       sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
 outreg2 using matches.xls, append  keep(t1_new t2_new) 
 reg changed_last_name_p1 t1_new t2_new ag1_new ag2_new ai_par_t_new       sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
 outreg2 using matches.xls, append  keep(t1_new t2_new) 
 
 
 /* Appendix Table 2 Matching Rates END */


 
 
 
/* Appendix Table 3 Cohort Comparisons BEGIN */

use gsms_main, clear



gen pa = 1 if ai_par_t>0 & ai_par_t<.
recode pa .=0 if ai_par_t ==0
gen init_inc = psb1x01 *5000

bysort agegrup pa :  sum   ai_par_t raceai  sex   mhs  mcol  init_inc  if wave ==1, separator(0)



*** T-Test Cohort 1 and 2 , Non AI 
 ttesti 370           0           0 359           0           0
 ttesti 370    .0189189    .1364232 359    .0362117    .1870773
 ttesti 370    .5621622    .4967926 359    .5961003    .4913627
 ttesti 370    .2972973    .4576874 359     .270195    .4446802
 ttesti 370    .4621622    .4992413 359    .5181058    .5003695
 ttesti  356    29367.98    17339.43   345    32652.17     17922.5

*** T-Test Cohort 2 and 3, Non AI
 ttesti 359           0           0 312           0           0 
 ttesti 359    .0362117    .1870773 312    .0705128    .2564206 
 ttesti 359    .5961003    .4913627 312     .525641    .5001443 
 ttesti 359     .270195    .4446802 312    .2788462    .4491521 
 ttesti 359    .5181058    .5003695 312    .4711538    .4999691 
 ttesti 345    32652.17     17922.5  297    32154.88    17395.53

*** T-Test Cohort 1 and 3, Non AI
  ttesti 370           0           0 312           0           0 
  ttesti 370    .0189189    .1364232 312    .0705128    .2564206 
  ttesti 370    .5621622    .4967926 312     .525641    .5001443 
  ttesti 370    .2972973    .4576874 312    .2788462    .4491521 
  ttesti 370    .4621622    .4992413 312    .4711538    .4999691 
  ttesti  356    29367.98    17339.43 297    32154.88    17395.53 




*** T-Test Cohort 1 and 2 , AI 

ttesti 110    1.354545    .4805647  106    1.386792    .4893291 
ttesti 110    .9272727    .2608768  106    .9811321    .1367049 
ttesti 110    .5090909    .5022053  106    .5471698    .5001348 
ttesti 110          .4    .4921401  106    .3301887     .472515 
ttesti 110    .3727273    .4857434  106    .4150943    .4950791 
ttesti  105    21952.38    15696.88     99    21212.12    15404.26  


*** T-Test Cohort 2 and 3,  AI
ttesti  106    1.386792    .4893291 81    1.296296    .4594683 
ttesti 106    .9811321    .1367049 81    .9259259    .2635231 
ttesti 106    .5471698    .5001348 81    .5432099     .501233 
ttesti 106    .3301887     .472515 81    .3333333    .4743416 
ttesti 106    .4150943    .4950791 81     .382716    .4890782 
ttesti  99    21212.12    15404.26     78       25000    16015.41


*** T-Test Cohort 1 and 3,  AI
ttesti 110    1.354545    .4805647 81    1.296296    .4594683 
ttesti 110    .9272727    .2608768 81    .9259259    .2635231 
ttesti 110    .5090909    .5022053 81    .5432099     .501233 
ttesti 110          .4    .4921401 81    .3333333    .4743416 
ttesti 110    .3727273    .4857434 81     .382716    .4890782 
ttesti 105    21952.38    15696.88   78       25000    16015.4

/* Appendix Table 3 Cohort Comparisons END */





/* Appendix Table 4 Comparison with other Tribes BEGIN */

* No Regressions **

/* Appendix Table 4 Comparison with other Tribes  END */





/* Appendix Table 5 Correlation Education and Voting BEGIN */
use parents, clear


 gen par_edu_new = 1 if paredu1 ==1 | paredu1==2
 recode par_edu_new . =2 if paredu1==3 | paredu1==4
 recode par_edu_new . =3 if paredu1==5 | paredu1==6| paredu1==7| paredu1==8
 recode par_edu_new . =4 if paredu1==9
 recode par_edu_new .=5 if paredu1==10| paredu1==11
 pwcorr votedtotal par_edu_new if year >1990 


/* Appendix Table 5 Correlation Education and Voting  END */





	
/* Appendix Table 6 First Stage Income BEGIN */
* Income First Stage *
cd "$dir"
clear
clear mata
clear matrix
set maxvar 20000
use gsms_diff_diff_nocollapse_082817.dta, clear

drop _merge

merge m:1 gsmsid wave using inc_alone


xi:reg inc_dollars2 casino  i.pa*i.agegrup  i.wave i.wave*i.agegrup pa if age <18 ,   r cluster(gsms)
outreg2 using firststage_fe.xls, replace keep(casino)


xi:xtreg inc_dollars2 casino  i.pa*i.agegrup  i.wave i.wave*i.agegrup pa if age <18, fe  r cluster(gsms)
outreg2 using firststage_fe.xls, append keep(casino)


tab wave, gen(wv)

gen agt=1 if ag1==1 | ag2==1
recode agt . =0 if ag3==1
drop ag1
gen ag1 = agt

gen int1=wv1*pa*ag1
gen int2=wv2*pa*ag1
gen int3=wv3*pa*ag1
gen int4=wv4*pa*ag1
gen int5=wv5*pa*ag1
gen int6=wv6*pa*ag1
gen int7=wv7*pa*ag1
gen int8=wv8*pa*ag1





xi:reg inc_dollars2 int1-int3 int5-int8   i.pa*i.agegrup  i.wave i.wave*i.agegrup pa if age <18 ,  r cluster(gsms)
outreg2 using firststage_fe.xls, append keep(int1-int8)


xi:xtreg inc_dollars2 int1-int3 int5-int8   i.pa*i.agegrup  i.wave i.wave*i.agegrup pa if age <18, fe r cluster(gsms)
outreg2 using firststage_fe.xls, append keep(int1-int8)

/* Appendix Table 6 First Stage Income BEGIN */





/* Appendix Table 7 Parents' Diff in Diff BEGIN */

use parents, clear

gen inter_triple = after*ai_par_tt*avghhincome
gen ai_par_tt_inc = avghhincome*ai_par_tt
gen after_inc = after*avghhincome

encode gsmsid, gen(newid)
xtset newid year

/* Parents Diff in Diff by Individual Cohorts FE */
xtreg votedtotal  interaction after ai_par_tt i.year  ag1_new ag2_new avghhincome_new if year>1990 ,  cl(gsms) r fe
outreg2 using parents_diff.xls, excel replace
sum votedtotal if e(sample)

/* Triple Parents Diff in Diff by Individual Cohorts FE  */
xtreg votedtotal  inter_triple ai_par_tt_inc after_inc interaction after ai_par_tt i.year avghhincome_new if year>1990,  cl(gsms) r fe
outreg2 using parents_diff.xls, excel append
sum votedtotal if e(sample)

/* Parents Diff in Diff by Median HH Income Fe */
xtreg votedtotal   interaction after ai_par_tt i.year if year>1990 & avghhincome_new<=5.33,  cl(gsms) r fe
outreg2 using parents_diff.xls, excel append
sum votedtotal if e(sample)
xtreg votedtotal  interaction after ai_par_tt i.year if year>1990 & avghhincome_new>5.33 & avghhincome<.,  cl(gsms) r fe
outreg2 using parents_diff.xls, excel append
sum votedtotal if e(sample)

/* Appendix Table 7 Parents' Diff in Diff END */





/* Appendix Table 8 Parents' Diff in Diff with Parental Age BEGIN */

use parents, clear

/* Figure 2 For Parental Vote Turn Out Prior to Casino by Initial HH Income */
xtile pc_inc =avghhincome_new, n(3)

sum voted_ if pc_inc ==1 & year>1990 & year<2014
sum voted_ if pc_inc ==2 & year>1990 & year<2014
sum voted_ if pc_inc ==3 & year>1990 & year<2014
/* Figure For Parental Vote Turn Out Prior to Casino by Initial HH Income END */

/* Appendix Table 4 BEGIN */
 gen par_edu_new = 1 if paredu1 ==1 | paredu1==2
 recode par_edu_new . =2 if paredu1==3 | paredu1==4
 recode par_edu_new . =3 if paredu1==5 | paredu1==6| paredu1==7| paredu1==8
 recode par_edu_new . =4 if paredu1==9
 recode par_edu_new .=5 if paredu1==10| paredu1==11
 

 pwcorr votedtotal par_edu_new if year >1990 
/* Appendix Table 4 END */

/* Table 1 Means Parental Voting Begin */
bysort ai_par_tt: sum votedtotal if year < 2014 & year>1990
ttest votedtotal if year < 2014 & year>1990, by(ai_par_tt) 

gen inter_inc= avghhincome_new*interaction
gen ai_inc=ai_par_tt*avghhincome_new
gen after_inc = after*avghhincome_new 

gen above =0 if avghhincome_new<=5.33
replace above =1 if avghhincome_new>5.33


gen inter_mage=mage*inter
gen after_mage=after*mage
gen ai_par_tt_mage = mage*ai_par_tt
reg votedtotal inter_mage after_mage ai_par_tt_mage mage inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if year>1990,   cl(gsms)
outreg2 using parents_cohort_mage.xls, excel replace



reg votedtotal inter_mage after_mage ai_par_tt_mage mage inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if avghhincome_new<=5.33 & year>1990,   cl(gsms)
outreg2 using parents_cohort_mage.xls, excel append



reg votedtotal inter_mage after_mage ai_par_tt_mage mage inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if avghhincome_new>5.33 & avghhincome_new<. & year>1990,   cl(gsms)
outreg2 using parents_cohort_mage.xls, excel append

/* Appendix Table 8 Parents' Diff in Diff with Parental Age END */









/* Appendix Table 9 Parents Event Analysis Regression BEGIN */
use parents, clear
*** For Event Analysis Parents by Race ***
reg votedtotal  int1 int2  int4-int12   i.year  ai_par_tt  ag1_new ag2_new avghhincome_new if year >1990,  cl(gsms)
outreg2 using parents.xls, excel replace
reg votedtotal  int1 int2  int4-int12   i.year  ai_par_tt  ag1_new ag2_new if year >1990 & avghhincome_new<=5.33,  cl(gsms)
outreg2 using parents.xls, excel append
reg votedtotal  int1 int2  int4-int12   i.year  ai_par_tt  ag1_new ag2_new if year >1990 & avghhincome_new>5.33 & avghhincome<.,  cl(gsms)
outreg2 using parents.xls, excel append
/* Appendix Table 9 Parents Event Analysis Regression END */




/* Appendix Table 10 Children DIff in Diff BEGIN */

****************************** Results, Unweighted, With Baseline Vote Propensity (in in-text table and figure)
use gsms_diff_diff_16_finished.dta, clear


 
/////*** Triple Interaction with Initial HH Income *//////
gen aa1 = t1_new*avghhincome_new
gen aa2 = t2_new*avghhincome_new
gen ai_inc=ai_par_t_new*avghhincome_new
gen ag1_inc=ag1_new*avghhincome_new
gen ag2_inc=ag2_new*avghhincome_new

gen agt=1 if ag1_new==1 |ag2_new ==1
recode agt . =0 if ag3_new==1
gen ag1 = agt

gen interaction=ag1*ai_par_t_new
 
gen voted_2002=voted_11_05_2002
gen voted_2004=voted_11_02_2004
gen voted_2006=voted_11_07_2006
gen voted_2008=voted_11_04_2008
gen voted_2010=voted_11_02_2010
gen voted_2012=voted_11_06_2012
gen voted_2014=voted_11_04_2014

gen voted_first = voted_2002 if ag3_new ==1 
replace voted_first = voted_2006 if ag1_new ==1

replace t1_new =1 if t1_new ==2
replace t2_new =1 if t2_new ==2
replace ai_par_t_new =1 if ai_par_t_new ==2
recode interaction 2=1

*** Counter ==2 is for first parent, counter ==3 is second parent
sort gsmsid parentid
by gsmsid: gen counter=_n if parentid ~=""
 
save temp, replace
*** PANEL 1, Columns 1 and 2: Pooled***
reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
outreg2 using kids_voting.xls, replace  keep(t1_new t2_new parent_base_prop_vote avghhincome_new)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote avghhincome_new)
sum ever_vote prop_vote if e(sample) 



*** PANEL 1, Columns 3 and 4: Pooled ***
drop aa1 aa2 ai_inc ag1_inc ag2_inc
gen aa1 = t1_new*avghhincome_new
gen aa2 = t2_new*avghhincome_new
gen ai_inc=ai_par_t_new*avghhincome_new
gen ag1_inc=ag1_new*avghhincome_new
gen ag2_inc=ag2_new*avghhincome_new

reg ever_vote aa1 aa2 ai_inc ag1_inc ag2_inc t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new    sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
outreg2 using kids_voting.xls, replace keep(t1_new t2_new parent_base_prop_vote aa1 aa2 avghhincome_new)
reg prop_vote aa1 aa2 ai_inc ag1_inc ag2_inc t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new    sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote aa1 aa2 avghhincome_new)
sum ever_vote prop_vote if e(sample)

*** PANEL 2: By Median HH Income *
*** Below Median HH Income ***
reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new    sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new    sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
sum ever_vote prop_vote if e(sample)
*** Above Median HH Income  ***
reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new    sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_new    sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
sum ever_vote prop_vote if e(sample)


/* Appendix Table 10 Children DIff in Diff END */


/* Appendix Table 11 Children DIff in Diff No Covariates BEGIN */
use temp, clear

*** PANEL 1, Columns 1 and 2: Pooled***
reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new      if parent==0 & avghhincome_new ~=., r
outreg2 using kids_voting.xls, replace  keep(t1_new t2_new parent_base_prop_vote avghhincome_new)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new      if parent==0 & avghhincome_new ~=., r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote avghhincome_new)
sum ever_vote prop_vote if e(sample) 


*** PANEL 1, Columns 3 and 4: Pooled ***
drop aa1 aa2 ai_inc ag1_inc ag2_inc
gen aa1 = t1_new*avghhincome_new
gen aa2 = t2_new*avghhincome_new
gen ai_inc=ai_par_t_new*avghhincome_new
gen ag1_inc=ag1_new*avghhincome_new
gen ag2_inc=ag2_new*avghhincome_new

reg ever_vote aa1 aa2 ai_inc ag1_inc ag2_inc t1_new t2_new ag1_new ag2_new ai_par_t_new avghhincome_new   if parent==0, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote aa1 aa2 avghhincome_new)
reg prop_vote aa1 aa2 ai_inc ag1_inc ag2_inc t1_new t2_new ag1_new ag2_new ai_par_t_new  avghhincome_new  if parent==0, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote aa1 aa2 avghhincome_new)
sum ever_vote prop_vote if e(sample)

*** PANEL 2: By Median HH Income *
*** Below Median HH Income ***
reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new    if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new        if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
sum ever_vote prop_vote if e(sample)
*** Above Median HH Income  ***
reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new    if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote)
sum ever_vote prop_vote if e(sample)


/* Appendix Table 11 Children DIff in Diff No Covariates END */










/* Appendix Table 12 Children Percent Income BEGIN */
use temp, clear
gen avghhincome_dollars = avghhincome*5000
gen percent_effect = 4690/avghhincome_dollars
replace ai_par_t_new =percent_effect if ai_par_t_new ==1
replace t1_new = ag1_new*ai_par_t_new
replace t2_new = ag2_new*ai_par_t_new


reg ever_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_dollars     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
outreg2 using kids_voting.xls, replace  keep(t1_new t2_new parent_base_prop_vote avghhincome_new)
reg prop_vote t1_new t2_new ag1_new ag2_new ai_par_t_new   avghhincome_dollars     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0, r
outreg2 using kids_voting.xls, append keep(t1_new t2_new parent_base_prop_vote avghhincome_new)
sum ever_vote prop_vote if e(sample)

/* Appendix Table 12 Children Percent Income END */




/* Appendix Table 13 Children Initial HH Income BEGIN */
use temp, clear

keep if parent ==0


sum   voted_2002 voted_2004 voted_2006 voted_2008 voted_2010 voted_2012 voted_2014 if (ag1_new==1 |ag2_new ==1) & (ai_par_t==1 | ai_par_t==2)
sum   voted_2002 voted_2004 voted_2006 voted_2008 voted_2010 voted_2012 voted_2014 if (ag1_new==1 |ag2_new ==1) & (ai_par_t==0)


sum   voted_2002 voted_2004 voted_2006 voted_2008 voted_2010 voted_2012 voted_2014 if (ag3_new==1) & (ai_par_t==1 | ai_par_t==2)
sum   voted_2002 voted_2004 voted_2006 voted_2008 voted_2010 voted_2012 voted_2014 if (ag3_new==1 ) & (ai_par_t==0)

reshape long voted_, i(gsmsid) j(year1)


tab year1, gen(yr)


encode gsmsid, gen(gsms)

tsset gsms year

gen after =1 if (year >1996 & year <.) 
recode after . =0 if year ~=. 

gen ai_par_tt=ai_par_t
recode ai_par_tt 2=1


gen ag1ai=ag1_new*ai_par_tt
gen ag2ai=ag2_new*ai_par_tt



reg voted_  ag1ai ag2ai ag1_new ag2_new ai_par_tt i.year  ag1_new ag2_new parent_base_prop_vote avghhincome_new,  cl(gsms) r
outreg2 using kids_voting.xls, replace 
reg voted_  ag1ai ag2ai ag1_new ag2_new ai_par_tt i.year  ag1_new ag2_new parent_base_prop_vote if  avghhincome_new<=5.33 ,  cl(gsms) r
outreg2 using kids_voting.xls, append 
reg voted_  ag1ai ag2ai ag1_new ag2_new ai_par_tt i.year  ag1_new ag2_new parent_base_prop_vote if avghhincome_new>5.33 & avghhincome_new<.,  cl(gsms) r
outreg2 using kids_voting.xls, append 

gen int1=yr1*ag1*ai_par_tt
gen int2=yr2*ag1*ai_par_tt
gen int3=yr3*ag1*ai_par_tt
gen int4=yr4*ag1*ai_par_tt
gen int5=yr5*ag1*ai_par_tt
gen int6=yr6*ag1*ai_par_tt
gen int7=yr7*ag1*ai_par_tt

xi:reg voted_  int2-int7  ai_par_tt ag1 i.ag1*i.year i.year i.ai_par_tt*i.year  age_days_1_1_1992 parent_base_prop_vote if avghhincome_new<=5.33 ,  cl(gsms) r
outreg2 using kids.xls, replace keep(int2-int7 parent_base_prop_vote) 
xi:reg voted_  int2-int7  ai_par_tt ag1 i.ag1*i.year i.year i.ai_par_tt*i.year  age_days_1_1_1992 parent_base_prop_vote if avghhincome_new>5.33 & avghhincome_new<.,  cl(gsms) r
outreg2 using kids.xls, append keep(int2-int7 parent_base_prop_vote) 




/* Appendix Table 13 Children Initial HH Income END */



/* Appendix Table 14 Children Combined Cohorts BEGIN */
use temp, clear

*** Pooled***
reg ever_vote interaction ai_par_t_new  ag1 avghhincome_new     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote  if parent==0, r
outreg2 using kids_voting.xls, replace  keep(interaction parent_base_prop_vote)
reg prop_vote interaction ai_par_t_new  ag1 avghhincome_new     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote  if parent==0, r
outreg2 using kids_voting.xls, append keep(interaction parent_base_prop_vote)
*** Below Median HH Income ***
reg ever_vote interaction ai_par_t_new  ag1     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_voting.xls, append keep(interaction parent_base_prop_vote)
reg prop_vote interaction ai_par_t_new  ag1      sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_voting.xls, append keep(interaction parent_base_prop_vote)
*** Above Median HH Income  ***
reg ever_vote interaction ai_par_t_new  ag1     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_voting.xls, append keep(interaction parent_base_prop_vote)
reg prop_vote interaction ai_par_t_new  ag1      sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_voting.xls, append keep(interaction parent_base_prop_vote)




/* Appendix Table 14 Children Combined Cohorts END */




/* Appendix Table 15 Mother's Educational Attainment BEGIN */

use moving, clear

drop _merge
*merge m:m gsmsid wave using temp1

merge m:m gsmsid  using newone

** Some College or Less
gen mother_hs =1 if medu ==3 | medu ==4 |medu==5 |medu==6
recode mother_hs . =0



gen fulltime_mom =1 if laborm ==0 
recode fulltime_mom . =0 if laborm ~=. 


encode gsmsid, gen(gsms)

gen aiparents=ai_par_t_new
recode aiparents 2=1


**** By Children's Regression Analysis in Cohorts Alone

replace t1_new =1 if t1_new ==2
replace t2_new =1 if t2_new ==2
replace ai_par_t_new =1 if ai_par_t_new ==2

*** Mother HS and Some College
xi: reg  mother_hs t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent ==0 & wave ==1,  
outreg2 using par_edu.xls, replace keep(t1_new t2_new)
sum mother_hs if e(sample)
xi: reg  mother_hs t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent ==0 & wave ==1 & avghhincome_old<=5.33,  
outreg2 using par_edu.xls, append keep(t1_new t2_new)
sum mother_hs if e(sample)
xi: reg  mother_hs t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent ==0 & wave ==1 & avghhincome_old>5.33 & avghhincome_old<.,  
outreg2 using par_edu.xls, append keep(t1_new t2_new)
sum mother_hs if e(sample)


*** Mother's Employment***
xi: reg  fulltime_mom t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent ==0 & wave ==1,  r
outreg2 using par_edu.xls, append keep(t1_new t2_new)
sum fulltime_mom if e(sample)
xi: reg  fulltime_mom t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent ==0 & wave ==1 & avghhincome_old<=5.33,  r
outreg2 using par_edu.xls, append keep(t1_new t2_new)
sum fulltime_mom if e(sample)
xi: reg  fulltime_mom t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent ==0 & wave ==1 & avghhincome_old>5.33& avghhincome_old<.,  r
outreg2 using par_edu.xls, append keep(t1_new t2_new)
sum fulltime_mom if e(sample)

/* Appendix Table 15 Mother's Educational Attainment END */






/* Appendix Table 16 Child Voting by Moving / Location BEGIN */

use moving, clear


replace t1_new =1 if t1_new ==2
replace t2_new =1 if t2_new ==2
replace ai_par_t_new =1 if ai_par_t_new ==2


reg changer_max t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent==0 , r
outreg2 using moving_table.xls, replace keep(t1_new t2_new)
sum ever_vote if e(sample)
reg changer_max t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent==0 &  avghhincome_new<=5.33, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)
reg changer_max t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent==0 &  avghhincome_new>5.33, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)


/* Appendix Table 16 Child Voting by Moving / Location END */



/* Appendix Table 17 Moving During Childhood BEGIN */
use moving, clear


replace t1_new =1 if t1_new ==2
replace t2_new =1 if t2_new ==2
replace ai_par_t_new =1 if ai_par_t_new ==2

*** Pooled
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent==0 &  changer_max==1, r
outreg2 using moving_table.xls, replace keep(t1_new t2_new)
sum ever_vote if e(sample)
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote avghhincome_new if parent==0 &  changer_max==0, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)
*** Moved During Childhood
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new       sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new<=5.33 & changer_max==1, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new<=5.33 & changer_max==0, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)

reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new     sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. & changer_max==1, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. & changer_max==0, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)

*** Note: Not driven by those who live outside of NC
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new<=5.33 & live_outside_nc==1, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new<=5.33 & live_outside_nc==0, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)

reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. & live_outside_nc==1, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)
reg ever_vote t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. & live_outside_nc==0, r
outreg2 using moving_table.xls, append keep(t1_new t2_new)
sum ever_vote if e(sample)

/* Appendix Table 17 Moving During Childhood END */





/* Appendix Table 18 Child's High School Completion BEGIN */

use moving, clear
drop _merge

*****Child Edu at Age 30*****
replace t1_new =1 if t1_new ==2
replace t2_new =1 if t2_new ==2
replace ai_par_t_new =1 if ai_par_t_new ==2

keep if parent ==0
merge 1:m gsmsid using temp_edu.dta
*** Note: Excerpt from gsms5_1.dta****

reg hsgrad t1_new t2_new ai_par_t_new  ag1_new ag2_new   avghhincome_new   sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if adult0==1, r
outreg2 using child_edu.xls, replace keep(t1_new t2_new)
reg hsgrad t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote if adult0==1 & avghhincome_new<=5.33 , r
outreg2 using child_edu.xls, append keep(t1_new t2_new)
reg hsgrad t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote if adult0==1 & avghhincome_new>5.33 , r
outreg2 using child_edu.xls, append keep(t1_new t2_new)

/* Appendix Table 18 Child's High School Completion END */






/* Appendix Table 19 Children's Social Characteristics BEGIN */
use moving, clear

drop _merge
merge m:1 gsmsid  using newone

replace t1_new =1 if t1_new ==2
replace t2_new =1 if t2_new ==2
replace ai_par_t_new =1 if ai_par_t_new ==2


gen friends_withdrawal_gen= friends_withdrawal_15 + friends_withdrawalp_15
replace friends_withdrawal_gen=1 if friends_withdrawal_gen>0 & friends_withdrawal_gen<.
* withrawn 0 absent 2 sometimes 3 always
reg friends_withdrawal_gen t1_new t2_new ai_par_t_new  ag1_new ag2_new        sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new<=5.33, r
outreg2 using child_connections.xls, append keep(t1_new t2_new)
sum friends_withdrawal_gen if e(sample)
reg friends_withdrawal_gen t1_new t2_new ai_par_t_new  ag1_new ag2_new       sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using child_connections.xls, append keep(t1_new t2_new)
sum friends_withdrawal_gen if e(sample)

gen rulebreak_gen= rulebreakp_15 + rulebreak_15
replace rulebreak_gen=1 if rulebreak_gen>0 & rulebreak_gen<.
* 0 2 rulebreaking in at least 2 activities 3 most activities
reg rulebreak_gen t1_new t2_new ai_par_t_new  ag1_new ag2_new        sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new<=5.33, r
outreg2 using child_connections.xls, append keep(t1_new t2_new)
sum rulebreak_gen if e(sample)
reg rulebreak_gen t1_new t2_new ai_par_t_new  ag1_new ag2_new      sex_new less6_new age_days_1_1_1992  parent_base_prop_vote  if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using child_connections.xls, append keep(t1_new t2_new)
sum rulebreak_gen if e(sample)


/* Appendix Table 19 Children's Social Characteristics END */






/* Appendix Table 20 Children's Voting at Similar Ages BEGIN */

use temp, clear

recode interaction 2=1
recode ai_par_t_new 2=1
reg voted_first interaction ai_par_t_new  ag1 avghhincome_new    sex_new less6_new age_days_1_1_1992 avghhincome_new  parent_base_prop_vote if parent==0 , r
outreg2 using kids_first.xls, replace keep(interaction)
reg voted_first interaction ai_par_t_new  ag1     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33 , r
outreg2 using kids_first.xls, append keep(interaction)
reg voted_first interaction ai_par_t_new  ag1     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_first.xls, append keep(interaction)

*** Voting in First Election where all are eligible;  All Cohorts Included ***
reg voted_2002 interaction ai_par_t_new  ag1 avghhincome_new    sex_new less6_new age_days_1_1_1992 avghhincome_new  parent_base_prop_vote if parent==0 , r
outreg2 using kids_first.xls, append keep(interaction)
reg voted_2002 interaction ai_par_t_new  ag1     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new<=5.33, r
outreg2 using kids_first.xls, append keep(interaction)
reg voted_2002 interaction ai_par_t_new  ag1     sex_new less6_new age_days_1_1_1992   parent_base_prop_vote if parent==0 & avghhincome_new>5.33 & avghhincome_new<. , r
outreg2 using kids_first.xls, append keep(interaction)


/* Appendix Table 20 Children's Voting at Similar Ages END */






/* Appendix Table 21 Parents' Voter Turnout BEGIN */
use parents, clear


*** Right Side Top
reg votedtotal inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if year>1990,   cl(gsms)
outreg2 using parents_cohort.xls, excel replace
sum votedtotal if e(sample)
reg votedtotal inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if avghhincome_new<=5.33 & year>1990,   cl(gsms)
outreg2 using parents_cohort.xls, excel append
sum votedtotal if e(sample)
reg votedtotal inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if avghhincome_new>5.33 & avghhincome_new<. & year>1990,   cl(gsms)
outreg2 using parents_cohort.xls, excel append
sum votedtotal if e(sample)

*** Right Side Bottom
reg votedtotal inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if year>1990 [pweight=match_weight],  cl(gsms) r
outreg2 using parents_cohort.xls, excel replace
reg votedtotal inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if avghhincome_new<=5.33 & year>1990 [pweight=match_weight],  cl(gsms) r
outreg2 using parents_cohort.xls, excel append
reg votedtotal inter after ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if avghhincome_new>5.33 & avghhincome_new<. & year>1990 [pweight=match_weight],  cl(gsms) r
outreg2 using parents_cohort.xls, excel append

*** Left Side Top 
reg votedtotal  t1_p t2_p ag1_new ag2_new ai_par_tt i.year avghhincome_new if year>1990 ,  cl(gsms) r
outreg2 using parents_diff.xls, excel replace
reg votedtotal   t1_p t2_p ag1_new ag2_new ai_par_tt i.year if year>1990 & avghhincome_new<=5.33,  cl(gsms) r
outreg2 using parents_diff.xls, excel append
reg votedtotal  t1_p t2_p ag1_new ag2_new ai_par_tt i.year if year>1990 & avghhincome_new>5.33 & avghhincome<.,  cl(gsms) r
outreg2 using parents_diff.xls, excel append

*** Left Side Bottom
reg votedtotal  t1_p t2_p ag1_new ag2_new ai_par_tt i.year avghhincome_new if year>1990 [pweight=match_weight],  cl(gsms) r
outreg2 using parents_diff.xls, excel append
reg votedtotal   t1_p t2_p ag1_new ag2_new ai_par_tt i.year if year>1990 & avghhincome_new<=5.33 [pweight=match_weight],  cl(gsms) r
outreg2 using parents_diff.xls, excel append
reg votedtotal  t1_p t2_p ag1_new ag2_new ai_par_tt i.year if year>1990 & avghhincome_new>5.33 & avghhincome<. [pweight=match_weight],  cl(gsms) r
outreg2 using parents_diff.xls, excel append

/* Appendix Table 21 Parents' Voter Turnout END */



/* Appendix Table 22 Parents event analysis Cohort Analysis BEGIN */
use parents, clear
reg votedtotal  intc1 intc2  intc4-intc12   ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 avghhincome_new if year >1990,  cl(gsms)
outreg2 using parents.xls, excel replace
reg votedtotal  intc1 intc2  intc4-intc12   ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if year >1990 & avghhincome_new<=5.33,  cl(gsms)
outreg2 using parents.xls, excel append
reg votedtotal  intc1 intc2  intc4-intc12   ai_par_tt i.year year i.race_yr i.race_agegrup i.yr_agegrup ag1 if year >1990 & avghhincome_new>5.33 & avghhincome<.,  cl(gsms)
outreg2 using parents.xls, excel append

/* Appendix Table 22 Parents event analysis Cohort Analysis END */

